<template>
  <div class="box">
    <div class="container">
      <div class="search-box">
        <div class="search-top-box" :style="moreSearchShow?'height:200px;overflow-y:auto':''">
          <div class="search-top-left-box">
            <el-form label-width="100px" ref="div" :inline="true" :model="formSearch" class="demo-form-inline">
              <el-form-item label="合同编号">
                <el-input clearable class="form-width" v-model="formSearch.num" placeholder=""></el-input>
              </el-form-item>
              <el-form-item label="项目名称">
                <el-input clearable class="form-width" v-model="formSearch.project_name" placeholder=""></el-input>
              </el-form-item>
              <el-form-item label="客户名称">
                <el-input clearable class="form-width" v-model="formSearch.client_name" placeholder=""></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div class="search-top-right-box">
            <p v-if="showOpne" @click="moreSearch">{{moreSearchShow?'收起':'展开'}}<i
                :class="moreSearchShow?'el-icon-arrow-up':'el-icon-arrow-down'"></i></p>
            <el-button type="primary" @click="onSearch">查询</el-button>
          </div>
        </div>
      </div>
      <el-table :header-cell-style="{background:'#FAFBFC',color:'#828A9D',textAlign:'center'}"
        :cell-style="{textAlign:'center',color:'#1B2431'}" :data="tableData" style="width: 100%;">
        <el-table-column prop="numbers" label="项目编号" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="contract_name" label="项目名称" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="project_name" label="项目状态" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="project_name" label="创建" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="address" label="操作" width="250">
          <template slot-scope="scope">
            <el-button size="mini">详情</el-button>
            <el-button size="mini" type="primary">通过</el-button>
            <el-button size="mini" type="danger">驳回</el-button>
          </template>
        </el-table-column>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination class="el-pagination" @current-change="handleCurrentChange" :current-page="page" :page-size="num"
      layout="prev, pager, next, jumper" :total="total">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    name: '',
    components: {},
    data() {
      return {
        page: 1,
        num: 10,
        total: 0,
        tableData: [1,2],
        formSearch: {
          project_name: '',
          num: '',
          client_name: '',
          type: ''
        },
        moreSearchShow: false,
        showOpne: false
      }
    },
    computed: {

    },
    watch: {
      dialogVisible(val1, val2) {
        if (!this.dialogVisible) {
          this.$refs['ruleForm'].resetFields();
        }
      },
    },
    destroyed() {
      window.onresize = null;
    },
    mounted() {
      this.$once('hook:beforeDestroy', function () {
        window.onresize = null;
      })
      this.onresize(); //监听搜索容器变化
      window.onresize = () => {
        this.onresize(); //监听搜索容器变化
      }
    },
    methods: {
      // 搜索
      onSearch() {
        this.page = 1;
        this.getContractList();
      },
      // 翻页
      handleCurrentChange(page) {
        this.page = page;
        this.getContractList();
      },
      onresize() {
        let inter = '';
        clearTimeout(inter)
        inter = setTimeout(() => {
          if (!this.$refs.div) return;
          let height = this.$refs.div.$el.offsetHeight;
          height > 70 ? this.showOpne = true : this.showOpne = false;
          this.moreSearchShow = false;
        }, 1000);
      },
      moreSearch() {
        this.moreSearchShow = !this.moreSearchShow;
      }
    }
  }

</script>

<style lang="scss" scoped>
  @import './index.scss';

</style>
